package com.botu.springclouddubboprovider.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.botu.api.DubboService;
import org.springframework.beans.factory.annotation.Value;
import org.apache.dubbo.config.annotation.Service;

import java.util.concurrent.TimeUnit;

/**
 * @Author: hanzeyao
 * @Date: 2019/12/14 15:18
 * @Description:
 */
@Service
public class DubboServiceImpl implements DubboService {

    @Value("${server.port}")
    private String port;

    @Override
    public String hello(String name) {
        return "Hello "+name;
    }

    @Override
    public String sayHello(String name) {
        try {
            TimeUnit.MILLISECONDS.sleep(50);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "Say, Hello " + name;
    }

    @Override
    public String demo(String name) {
        return "测试注解 "+name;
    }

    @Override
    @SentinelResource(value = "authority",fallback = "authorityFlow")
    public String authority() {
        return "==pass==";
    }

    /**
     * 测试nacos的权重设置
     * @return
     */
    @Override
    public String weight() {
        return port;
    }

    public String authorityFlow(){
        return "黑名单限制";
    }


}
